//
//  ComicTableViewCell.m
//  QuickReadComic
//
//  Created by 苗钧豪 on 16/8/30.
//  Copyright © 2016年 苗钧豪. All rights reserved.
//

#import "ComicTableViewCell.h"

@implementation ComicTableViewCell

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUp];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    _numberBtn.selected = NO;
    [self.numberBtn addTarget:self action:@selector(good) forControlEvents:(UIControlEventTouchUpInside)];
    // Initialization code
}

- (void)setUp {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = [UIColor whiteColor];
    
}
- (void)good {
    if (_numberBtn.selected == NO) {
        _numberBtn.selected = YES;
        _goodImageview.image = [UIImage imageNamed:@"IMG_0430"];
        int number = [_numberBtn.titleLabel.text intValue];
        int newnumber = number + 1;
        [_numberBtn setTitle:[NSString stringWithFormat:@"%d",newnumber] forState:(UIControlStateNormal)];
        [_numberBtn setTitleColor:[UIColor colorWithRed:0.941 green:0.592 blue:0.000 alpha:1.000] forState:(UIControlStateNormal)];
    } else if (_numberBtn.selected == YES) {
        _numberBtn.selected = NO;
        _goodImageview.image = [UIImage imageNamed:@"002"];
        int number = [_numberBtn.titleLabel.text intValue];
        int newnumber = number - 1;
        [_numberBtn setTitle:[NSString stringWithFormat:@"%d",newnumber] forState:(UIControlStateNormal)];
        [_numberBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
